package com.yan.furns.dao.impl;

import com.yan.furns.dao.BasicDAO;
import com.yan.furns.dao.MemberDAO;
import com.yan.furns.entity.Member;

/**
 * @author Yzb
 * @version 1.0
 */
public class MemberDAOImpl extends BasicDAO<Member> implements MemberDAO {
	@Override
	public Member queryMemberByUsername(String username) {
		String sql = "select id, username, password, email" +
				" from member where username = ?";
		return querySingle(sql, Member.class, username);
	}

	@Override
	public Member queryMemberNyUsernameAndPassword(String username, String password) {
		String sql = "select id, username, password, email" +
				" from member where username = ? and password = md5(?)";
		return querySingle(sql, Member.class, username, password);
	}

	@Override
	public int saveMember(Member member) {
		String sql = "insert into member (username, password, email) values(?,md5(?),?)";
		return update(sql, member.getUsername(), member.getPassword(), member.getEmail());
	}
}
